<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Browse extends MY_Controller {

	function __construct() {
		parent::__construct();
	}
	
	public function index($catid='')
	{
		if ($this->isSessionActive()) {
		
			$this->load->model("Browse_model");
			
			$data['categories'] = $this->Browse_model->get_categories();
			
			$data['searchresult'] = $this->Browse_model->search($this->fb_id, $_POST, $catid);
			
			if ($catid)
				$data['selectedcat'] = $catid;
			$data['user'] = $this->fb_id;
			$data['title'] = 'Browse';
			$data['content_view'] = 'browse_view';
			$data['stylesheets'] = array('browse', 'paginate-style');
			$data['javascripts'] = array('browse', 'paginate', 'browse_paginate');

    		$this->load_template_view($data, TRUE);
		}
	}
	
	function search_result()
	{
		$this->load->model("Browse_model");
		$data = $this->Browse_model->search($this->fb_id, $_POST);
		echo json_encode($data);
	}
	
}